/**
 * 文件名：BaseAction.java
 *
 * 版本信息：
 * 日期：2009-6-17
 * Copyright dp Corporation 2009 
 * 版权所有 2009All rights reserved.
 * 创建者：wht
 *
 */
package com.dp.pub;
import java.lang.reflect.Method;
import java.lang.reflect.TypeVariable;
import java.util.Date;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;
import org.apache.struts2.interceptor.SessionAware;

import com.opensymphony.xwork2.ActionSupport;
/**
 * 
 * 项目名称：book
 * 类名称：BaseAction
 * 类描述：所有Action 的基类，目的是能获得session，和request，response
 * 创建人：Administrator
 * 创建时间：2009-6-17 下午02:03:44
 * 修改人：Administrator
 * 修改时间：2009-6-17 下午02:03:44
 * 修改备注：
 * @version 
 * 
 */

public class BaseAction extends ActionSupport implements SessionAware,ServletRequestAware, ServletResponseAware{	
	 protected Map<String, Object> session; 
	 protected HttpServletRequest request; 
	 protected HttpServletResponse response; 
	 protected String resultcode;
	 private static  org.apache.log4j.Logger logg=null;
//	 public String uploadroot = SysProperty.getPrep("uploadpath");
	 protected String curdate = (new java.text.SimpleDateFormat("yyyyMM")).format(new Date());
	 public void setSession(Map<String, Object> session) {	 this.session = session;}
	 public void setServletRequest(HttpServletRequest request) {		this.request = request;		}
	 public void setServletResponse(HttpServletResponse response) {		this.response = response;	}
	 protected void log(String message) 
	 { 
		 if(logg==null)logg =org.apache.log4j.Logger.getLogger(getClass());
		 logg.info(message);		 
	}
	 protected void log(String message,Throwable t) 
	 { 
		 if(logg==null)logg =org.apache.log4j.Logger.getLogger(getClass());
		 logg.info(message,t);
	}
	 
	 protected void createWhere(String... s)
	 {
		 Method method;
		try {
			method = this.getClass().getMethod("createWhere",String[].class);
			 TypeVariable<Method>[] types = method.getTypeParameters();
			 for(TypeVariable m:types)
			 {
				 System.out.println( m.getName()); 
			 }
			 
			 
		} catch (SecurityException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NoSuchMethodException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	 }
}

/*
publicclass IoCServlet extends ActionSupport implements SessionAware, ServletRequestAware, ServletResponseAware {
	private String message; 
	private Map att; 

 * 另外，org.apache.struts2.ServletActionContext作为辅助类（Helper Class），可以帮助您快捷地获得这几个对象。 

HttpServletRequest request = ServletActionContext.getRequest(); 
HttpServletResponse response = ServletActionContext.getResponse(); 
HttpSession session = request.getSession(); 

import com.opensymphony.xwork2.ActionContext; 
import com.opensymphony.xwork2.ActionSupport; 
public class SessionTestAction extends ActionSupport {
    public String execute() {
     ActionContext actionContext = ActionContext.getContext();
       Map session = actionContext.getSession(); 
       session.put("USER_NAME", "Test User"); 
       return SUCCESS; 
    } 
}
*/

